import http from '@/utils/http'

const BASE_URL = '/system/meetRoom'
/** @desc 查询会议日历 */
export function meetSchedule(conferenceState: number | string, year: string, month: string) {
  return http.get(`/oa/meetSchedule?conferenceState=${conferenceState}&year=${year}&month=${month}`)
}

/** @desc 服务项目管理列表 */
export function serviceItem(query) {
  return http.get(`/system/service?page=${query.page}&size=${query.size}`)
}
/** @desc 服务项目管理列表 */
export function serviceItemList() {
  return http.get(`/system/service`)
}

/** @desc 厂区管理列表 */
export function factory() {
  return http.get(`/system/meet/factory`)
}

/** @desc 添加服务项目 */
export function addservice(data: any) {
  return http.post(`/system/service`, data)
}

/** @desc 查询服务项目详情 */
export function getgetserviceDetail(id: string | number) {
  return http.get(`/system/service/${id}`)
}

/** @desc 查询服务项目详情 */
export function updateServiceDetail(data: any, id: string | number) {
  return http.put(`/system/service/${id}`, data)
}

/** @desc 删除服务项目 */
export function deleteServiceDetail(ids: any) {
  return http.del(`/system/service/${ids}`)
}

/** @desc 查询全部会议列表 */
export function getMeetingTask(query: any) {
  return http.get(`/system/service/searchAllServeNew?page=${query.page}&size=${query.size}`)
}

/** @desc 查询个人任务列表 */
export function getSearchMyServe(query: any) {
  return http.get(`/system/service/searchMyServeNew?page=${query.page}&size=${query.size}`)
}

// /** @desc 模糊查询服务项目管理 */
export function fuzzySearch(query: any) {
  return http.get(`/system/service?page=${query.page}&size=${query.size}&keywords=${query.keywords}`)
}

// /** @desc 模糊查询会议任务 */
export function meeetingTaskFuzzySearch(query: any) {
  return http.get(`/system/service/searchAllServeNew?page=${query.page}&size=${query.size}&keywords=${query.keywords}`)
}

// /** @desc 模糊查询个人任务 */
export function myTaskFuzzySearch(query: any) {
  return http.get(`/system/service/searchMyServeNew?page=${query.page}&size=${query.size}&keywords=${query.keywords}`)
}
/** @desc 模糊查询负责人 */

export function oaSearch(name: string) {
  const encodedName = encodeURIComponent(name)
  return http.get(`/contects/apptree/search?keyword=${encodedName}`)
}
/** @desc 查询负责人树状列表 */

export function contectsApptree() {
  return http.get(`/contects/apptree`)
}
/** @desc 新增会议 */

export function meetScheduledmeet(data: any) {
  return http.post(`/system/meet/scheduledmeet`, data)
}

/** @desc 查询签到参数部门 */

export function oaGetSignDept() {
  return http.get(`/oa/getSignDept`)
}
/** 查询签到参数部门（过滤空值版） */
export function oaStatisticsAbsentTop(query: any) {
  // 创建URLSearchParams自动过滤空值
  const params = new URLSearchParams()

  Object.entries(query).forEach(([key, value]) => {
    // 过滤 null/undefined/空字符串
    if (value != null && value !== '' && value !== 'null') {
      params.append(key, value)
    }
  })

  return http.get(`/oa/statistics/absentTop?${params}`)
}

/** @desc 获取会议缺席用户统计 */
export function getMeetAbsentUser() {
  return http.post('/oa/meetAbsentUser')
}
